博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
微信小程序保存图片功能实现
阅读量:6951 次
发布时间:2019-06-27

本文共 1691 字,大约阅读时间需要 5 分钟。

小程序保存图片功能实现

wxml:

wxss:

.previewImage{
position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: #000;}

 

 

js:

previewImg:function(){        this.setData({            previewImage:"block"        });    },    saveImg:function(){        longTouch = true;        this.setData({            saveImage:false        })    },    closePrev:function(){        if(longTouch){            longTouch = false;        }else{            this.setData({                previewImage:"none"            });        }    },    actionSheetChange:function(){        this.setData({            saveImage:!this.data.saveImage        })    },    downloadFile:function(e){        var imgUrl = e.currentTarget.dataset.imageHref;        var that = this;        wx.downloadFile({              url: imgUrl,              type: 'image',              success:function(res){                  var tempFilePath = res.tempFilePath;                console.log(tempFilePath);                wx.saveFile({                      tempFilePath:tempFilePath,                      success:function(res){                        var savedFilePath = res.savedFilePath;                        console.log(savedFilePath);                        that.setData({                            saveImage:true                        });                      },                      fail:function(res){                          console.log(res);                      }                });              },              fail:function(res){                  console.log(res);              }        });    }

 

转载地址:http://mqkil.baihongyu.com/

你可能感兴趣的文章
php获取时间问题,用默认配置读到本地时间。。。。。
查看>>
vim 介绍安装 复制 剪切 粘贴
查看>>
Android菜鸟的成长笔记(4)——你真的理解了吗?
查看>>
软件工程 part4 评价3作品 修改
查看>>
dfs的返回条件
查看>>
ASP.NET中Web.Config配置文件详解与应用
查看>>
Django之分页
查看>>
使用wkhtmltopdf的一些事情
查看>>
万达 恒大 万科
查看>>
【 OJ 】Score
查看>>
离开当当
查看>>
各种同步方法性能比较(synchronized,ReentrantLock,Atomic)
查看>>
idea报错项积累
查看>>
Express踩坑系列之初识Express
查看>>
不使用c的任何库函数 实现字符串到整数的转换 整数到字符串的转换
查看>>
Android BCM4330 蓝牙BT驱动调试记录
查看>>
mysql8.0.13安装
查看>>
[原创] Debian9上配置软件阵列
查看>>
远程控制数据库实用SQL重启功能
查看>>
svn备份一般采用三种方式
查看>>